<?php

namespace App\Policies;

use App\models\Topic;
use App\Models\User;

/**
 * 话题的策略
 *
 * Class TopicPolicy
 * @package App\Policies
 */
class TopicPolicy extends Policy
{
    /**
     * 更新话题权限仅是创建的人可以更新
     *
     * @param User $user
     * @param Topic $topic
     * @return bool
     */
    public function update(User $user, Topic $topic)
    {
        return $user->isAuthorOf($topic);
    }

    /**
     * 删除话题权限仅是创建的人可以删除
     *
     * @param User $user
     * @param Topic $topic
     * @return bool
     */
    public function destroy(User $user, Topic $topic)
    {
        return $user->isAuthorOf($topic);
    }
}
